[campsite-support] Need help with template
  • My article template doesn't show the link to the translation of the
    article. When I preview an article, I get a message about it:


    Parse errors:

    Invalid property translated_to of object Article


    If I remove {{ if $campsite->article->translated_to == "en" }} and {{
    /if }}, it shows the link, but on all articles regardless of whether
    they are translated, and the link points to the homepage if there is
    no translation.

    What code should I use in my template to check if an article is
    available in English or Chinese? I'm using Campsite 3.2.1.
    This is what I have now:

    {{ if $campsite->language->english_name == "Chinese" }}
    {{ if $campsite->article->translated_to == "en" }}
    {{ local }}
    {{ set_language name="english" }}

    {{ /local }}
    {{ /if }}
    {{ else }}
    {{ if $campsite->article->translated_to == "zh" }}
    {{ local }}
    {{ set_language name="chinese" }}

    {{ /local }}
    {{ /if }}
    {{ /if }}
  • 9 Comments sorted by
  • Hi Sebastian!

    You can set the language in the wanted output language with
    {{ set_language name="Chinese" }} like you have done but I have given
    more complete example few days ago (21st) to Pippa. Look forum subject
    "breadcrumbs".

    A bit misleading subject but it talks about the exact templating of
    your case.
    I hope this would help you. Note, that there are two different files
    that are working together but on the same page.

    Sanna @ Gene


    On 24.8.2009, at 23.43, Sebastian Olsson wrote:

    > My article template doesn't show the link to the translation of the
    > article. When I preview an article, I get a message about it:
    >
    >
    > Parse errors:
    >
    > Invalid property translated_to of object Article
    >
    >
    > If I remove {{ if $campsite->article->translated_to == "en" }} and {{
    > /if }}, it shows the link, but on all articles regardless of whether
    > they are translated, and the link points to the homepage if there is
    > no translation.
    >
    > What code should I use in my template to check if an article is
    > available in English or Chinese? I'm using Campsite 3.2.1.
    > This is what I have now:
    >
    > {{ if $campsite->language->english_name == "Chinese" }}
    > {{ if $campsite->article->translated_to == "en" }}
    > {{ local }}
    > {{ set_language name="english" }}
    >
    > {{ /local }}
    > {{ /if }}
    > {{ else }}
    > {{ if $campsite->article->translated_to == "zh" }}
    > {{ local }}
    > {{ set_language name="chinese" }}
    >
    > {{ /local }}
    > {{ /if }}
    > {{ /if }}
  • The proper syntax is:
    $campsite->article->translated_to()

    E.g.: $campsite->article->translated_to("en")

    See the manual page:
    http://code.campware.org/manuals/campsite/3.3/index.php?id9

    Mugur

    On Mon, Aug 24, 2009 at 11:43 PM, Sebastian Olsson <
    sebastian.olsson@socialisterna.org> wrote:

    > My article template doesn't show the link to the translation of the
    > article. When I preview an article, I get a message about it:
    >
    >
    > Parse errors:
    >
    > Invalid property translated_to of object Article
    >
    >
    > If I remove {{ if $campsite->article->translated_to == "en" }} and {{
    > /if }}, it shows the link, but on all articles regardless of whether
    > they are translated, and the link points to the homepage if there is
    > no translation.
    >
    > What code should I use in my template to check if an article is
    > available in English or Chinese? I'm using Campsite 3.2.1.
    > This is what I have now:
    >
    > {{ if $campsite->language->english_name == "Chinese" }}
    > {{ if $campsite->article->translated_to == "en" }}
    > {{ local }}
    > {{ set_language name="english" }}
    >
    > {{ /local }}
    > {{ /if }}
    > {{ else }}
    > {{ if $campsite->article->translated_to == "zh" }}
    > {{ local }}
    > {{ set_language name="chinese" }}
    >
    > {{ /local }}
    > {{ /if }}
    > {{ /if }}
    >
  • Thank you. It's working now.

    2009/8/25 Mugur Rus :
    > The proper syntax is:
    > $campsite->article->translated_to()
    >
    > E.g.: $campsite->article->translated_to("en")
    >
    > See the manual page:
    > http://code.campware.org/manuals/campsite/3.3/index.php?id9
    >
    > Mugur
    >
    > On Mon, Aug 24, 2009 at 11:43 PM, Sebastian Olsson
    > wrote:
    >>
    >> My article template doesn't show the link to the translation of the
    >> article. When I preview an article, I get a message about it:
    >>
    >>
    >> Parse errors:
    >>
    >> Invalid property translated_to of object Article
    >>
    >>
    >> If I remove {{ if $campsite->article->translated_to == "en" }} and {{
    >> /if }}, it shows the link, but on all articles regardless of whether
    >> they are translated, and the link points to the homepage if there is
    >> no translation.
    >>
    >> What code should I use in my template to check if an article is
    >> available in English or Chinese? I'm using Campsite 3.2.1.
    >> This is what I have now:
    >>
    >> {{ if $campsite->language->english_name == "Chinese" }}
    >> {{ if $campsite->article->translated_to == "en" }}
    >> {{ local }}
    >> {{ set_language name="english" }}
    >>
    >> {{ /local }}
    >> {{ /if }}
    >> {{ else }}
    >> {{ if $campsite->article->translated_to == "zh" }}
    >> {{ local }}
    >> {{ set_language name="chinese" }}
    >>
    >> {{ /local }}
    >> {{ /if }}
    >> {{ /if }}
    >
    >
  • I have another question about the templates syntax. This is what I'm
    trying to do:

    {{ if $campsite->current_list->at_end }}

    {{ if $campsite->current_list->has_previous_elements }}
    <<Previous
    {{ /if }}
    {{ if $campsite->current_list->has_next_elements }}
    Next>>
    {{ /if }}

    {{ /if }}

    I want it to continue to the next page and show the older articles
    when I click next, but it returns to the frontpage.

    Sebastian

    2009/8/25 Sebastian Olsson :
    > Thank you. It's working now.
    >
    > 2009/8/25 Mugur Rus :
    >> The proper syntax is:
    >> $campsite->article->translated_to()
    >>
    >> E.g.: $campsite->article->translated_to("en")
    >>
    >> See the manual page:
    >> http://code.campware.org/manuals/campsite/3.3/index.php?id9
    >>
    >> Mugur
    >>
    >> On Mon, Aug 24, 2009 at 11:43 PM, Sebastian Olsson
    >> wrote:
    >>>
    >>> My article template doesn't show the link to the translation of the
    >>> article. When I preview an article, I get a message about it:
    >>>
    >>>
    >>> Parse errors:
    >>>
    >>> Invalid property translated_to of object Article
    >>>
    >>>
    >>> If I remove {{ if $campsite->article->translated_to == "en" }} and {{
    >>> /if }}, it shows the link, but on all articles regardless of whether
    >>> they are translated, and the link points to the homepage if there is
    >>> no translation.
    >>>
    >>> What code should I use in my template to check if an article is
    >>> available in English or Chinese? I'm using Campsite 3.2.1.
    >>> This is what I have now:
    >>>
    >>> {{ if $campsite->language->english_name == "Chinese" }}
    >>> {{ if $campsite->article->translated_to == "en" }}
    >>> {{ local }}
    >>> {{ set_language name="english" }}
    >>>
    >>> {{ /local }}
    >>> {{ /if }}
    >>> {{ else }}
    >>> {{ if $campsite->article->translated_to == "zh" }}
    >>> {{ local }}
    >>> {{ set_language name="chinese" }}
    >>>
    >>> {{ /local }}
    >>> {{ /if }}
    >>> {{ /if }}
    >>
    >>
    >
  • Hi Sebastian,

    Please send us the complete template file, those lines look Ok but i
    guess there is something wrong around.

    Best,


    On Tue, Sep 1, 2009 at 5:50 AM, Sebastian
    Olsson wrote:
    > I have another question about the templates syntax. This is what I'm
    > trying to do:
    >
    > {{ if $campsite->current_list->at_end }}
    >  

    >  {{ if $campsite->current_list->has_previous_elements }}
    >    <<Previous
    >  {{ /if }}
    >  {{ if $campsite->current_list->has_next_elements }}
    >    Next>>
    >  {{ /if }}
    >  

    > {{ /if }}
    >
    > I want it to continue to the next page and show the older articles
    > when I click next, but it returns to the frontpage.
    >
    > Sebastian
    >
    > 2009/8/25 Sebastian Olsson :
    >> Thank you. It's working now.
    >>
    >> 2009/8/25 Mugur Rus :
    >>> The proper syntax is:
    >>> $campsite->article->translated_to()
    >>>
    >>> E.g.: $campsite->article->translated_to("en")
    >>>
    >>> See the manual page:
    >>> http://code.campware.org/manuals/campsite/3.3/index.php?id9
    >>>
    >>> Mugur
    >>>
    >>> On Mon, Aug 24, 2009 at 11:43 PM, Sebastian Olsson
    >>> wrote:
    >>>>
    >>>> My article template doesn't show the link to the translation of the
    >>>> article. When I preview an article, I get a message about it:
    >>>>
    >>>>
    >>>> Parse errors:
    >>>>
    >>>> Invalid property translated_to of object Article
    >>>>
    >>>>
    >>>> If I remove {{ if $campsite->article->translated_to == "en" }} and {{
    >>>> /if }}, it shows the link, but on all articles regardless of whether
    >>>> they are translated, and the link points to the homepage if there is
    >>>> no translation.
    >>>>
    >>>> What code should I use in my template to check if an article is
    >>>> available in English or Chinese? I'm using Campsite 3.2.1.
    >>>> This is what I have now:
    >>>>
    >>>> {{ if $campsite->language->english_name == "Chinese" }}
    >>>> {{ if $campsite->article->translated_to == "en" }}
    >>>> {{ local }}
    >>>> {{ set_language name="english" }}
    >>>>
    >>>> {{ /local }}
    >>>> {{ /if }}
    >>>> {{ else }}
    >>>> {{ if $campsite->article->translated_to == "zh" }}
    >>>> {{ local }}
    >>>> {{ set_language name="chinese" }}
    >>>>
    >>>> {{ /local }}
    >>>> {{ /if }}
    >>>> {{ /if }}
    >>>
    >>>
    >>
    >



    --
    /holman
  • This is the entire front.tpl:




    {{ local }}
    {{ set_language name="chinese" }}
    {{ list_articles length="15" constraints="type is news"
    order="bypublishdate desc" }}
    {{ if $campsite->article->has_image(1) }}
    src="/get_img.php?{{ urlparameters options="image 1" }}" border="0"
    alt="{{ $campsite->image->description }}">

    {{ /if }}
    {{ if $campsite->article->has_image(2) }}
    src="/get_img.php?{{ urlparameters options="image 2" }}" border="0"
    alt="{{ $campsite->image->description }}">

    {{ /if }}
    {{ if $campsite->article->has_image(3) }}
    src="/get_img.php?{{ urlparameters options="image 3" }}" border="0"
    alt="{{ $campsite->image->description }}">

    {{ /if }}
    {{ if $campsite->article->has_image(4) }}
    src="/get_img.php?{{ urlparameters options="image 4" }}" border="0"
    alt="{{ $campsite->image->description }}">

    {{ /if }}
    {{ if $campsite->article->has_image(5) }}
    src="/get_img.php?{{ urlparameters options="image 5" }}" border="0"
    alt="{{ $campsite->image->description }}">

    {{ /if }}
    {{ if $campsite->article->has_image(6) }}
    src="/get_img.php?{{ urlparameters options="image 6" }}" border="0"
    alt="{{ $campsite->image->description }}">

    {{ /if }}


    {{ $campsite->article->name
    }}


    {{
    $campsite->article->publish_date|camp_date_format:"%W, %e %M %Y."
    }}


    {{ $campsite->article->body->first_paragraph }}


    {{ if $campsite->current_list->at_end }}

    {{ if $campsite->current_list->has_previous_elements }}
    <<
  • Hi again Sebastian,

    I think you should try some like this for the "next" link:

    options="next_items" }}">>>

    or:

    options="next_items" }}">>>

    depends on how your structure is... anyway, think the first one will
    make the trick.

    Let us know how it goes.

    Best,



    2009/9/1 Sebastian Olsson :
    > This is the entire front.tpl:
    >
    >
    >
    >

    > {{ local }}
    > {{ set_language name="chinese" }}
    > {{ list_articles length="15" constraints="type is news"
    > order="bypublishdate desc" }}
    > {{ if $campsite->article->has_image(1) }}
    >
    > src="/get_img.php?{{ urlparameters options="image 1" }}" border="0"
    > alt="{{ $campsite->image->description }}">

    > {{ /if }}
    > {{ if $campsite->article->has_image(2) }}
    >
    > src="/get_img.php?{{ urlparameters options="image 2" }}" border="0"
    > alt="{{ $campsite->image->description }}">

    > {{ /if }}
    > {{ if $campsite->article->has_image(3) }}
    >
    > src="/get_img.php?{{ urlparameters options="image 3" }}" border="0"
    > alt="{{ $campsite->image->description }}">

    > {{ /if }}
    > {{ if $campsite->article->has_image(4) }}
    >
    > src="/get_img.php?{{ urlparameters options="image 4" }}" border="0"
    > alt="{{ $campsite->image->description }}">

    > {{ /if }}
    > {{ if $campsite->article->has_image(5) }}
    >
    > src="/get_img.php?{{ urlparameters options="image 5" }}" border="0"
    > alt="{{ $campsite->image->description }}">

    > {{ /if }}
    > {{ if $campsite->article->has_image(6) }}
    >
    > src="/get_img.php?{{ urlparameters options="image 6" }}" border="0"
    > alt="{{ $campsite->image->description }}">

    > {{ /if }}
    >


    > {{ $campsite->article->name
    > }}


    >

    {{
    > $campsite->article->publish_date|camp_date_format:"%W, %e %M %Y."
    > }}


    >

    {{ $campsite->article->body->first_paragraph }}


    > {{ if $campsite->current_list->at_end }}
    >

    > {{ if $campsite->current_list->has_previous_elements }}
    > <<
  • Yes. It works. Thank you!

    Sebastian

    2009/9/1 Holman Romero :
    > Hi again Sebastian,
    >
    > I think you should try some like this for the "next" link:
    >
    > > options="next_items" }}">>>
    >
    > or:
    >
    > > options="next_items" }}">>>
    >
    > depends on how your structure is... anyway, think the first one will
    > make the trick.
    >
    > Let us know how it goes.
    >
    > Best,
    >
    >
    >
    > 2009/9/1 Sebastian Olsson :
    >> This is the entire front.tpl:
    >>
    >>
    >>
    >>

    >> {{ local }}
    >> {{ set_language name="chinese" }}
    >> {{ list_articles length="15" constraints="type is news"
    >> order="bypublishdate desc" }}
    >> {{ if $campsite->article->has_image(1) }}
    >>
    >> src="/get_img.php?{{ urlparameters options="image 1" }}" border="0"
    >> alt="{{ $campsite->image->description }}">

    >> {{ /if }}
    >> {{ if $campsite->article->has_image(2) }}
    >>
    >> src="/get_img.php?{{ urlparameters options="image 2" }}" border="0"
    >> alt="{{ $campsite->image->description }}">

    >> {{ /if }}
    >> {{ if $campsite->article->has_image(3) }}
    >>
    >> src="/get_img.php?{{ urlparameters options="image 3" }}" border="0"
    >> alt="{{ $campsite->image->description }}">

    >> {{ /if }}
    >> {{ if $campsite->article->has_image(4) }}
    >>
    >> src="/get_img.php?{{ urlparameters options="image 4" }}" border="0"
    >> alt="{{ $campsite->image->description }}">

    >> {{ /if }}
    >> {{ if $campsite->article->has_image(5) }}
    >>
    >> src="/get_img.php?{{ urlparameters options="image 5" }}" border="0"
    >> alt="{{ $campsite->image->description }}">

    >> {{ /if }}
    >> {{ if $campsite->article->has_image(6) }}
    >>
    >> src="/get_img.php?{{ urlparameters options="image 6" }}" border="0"
    >> alt="{{ $campsite->image->description }}">

    >> {{ /if }}
    >>


    >> {{ $campsite->article->name
    >> }}


    >>

    {{
    >> $campsite->article->publish_date|camp_date_format:"%W, %e %M %Y."
    >> }}


    >>

    {{ $campsite->article->body->first_paragraph }}


    >> {{ if $campsite->current_list->at_end }}
    >>

    >> {{ if $campsite->current_list->has_previous_elements }}
    >> <<
  • Glad to know, was a pleasure !!


    2009/9/1 Sebastian Olsson :
    > Yes. It works. Thank you!
    >
    > Sebastian
    >
    > 2009/9/1 Holman Romero :
    >> Hi again Sebastian,
    >>
    >> I think you should try some like this for the "next" link:
    >>
    >> >> options="next_items" }}">>>
    >>
    >> or:
    >>
    >> >> options="next_items" }}">>>
    >>
    >> depends on how your structure is... anyway, think the first one will
    >> make the trick.
    >>
    >> Let us know how it goes.
    >>
    >> Best,
    >>
    >>
    >>
    >> 2009/9/1 Sebastian Olsson :
    >>> This is the entire front.tpl:
    >>>
    >>>
    >>>
    >>>

    >>> {{ local }}
    >>> {{ set_language name="chinese" }}
    >>> {{ list_articles length="15" constraints="type is news"
    >>> order="bypublishdate desc" }}
    >>> {{ if $campsite->article->has_image(1) }}
    >>>
    >>> src="/get_img.php?{{ urlparameters options="image 1" }}" border="0"
    >>> alt="{{ $campsite->image->description }}">

    >>> {{ /if }}
    >>> {{ if $campsite->article->has_image(2) }}
    >>>
    >>> src="/get_img.php?{{ urlparameters options="image 2" }}" border="0"
    >>> alt="{{ $campsite->image->description }}">

    >>> {{ /if }}
    >>> {{ if $campsite->article->has_image(3) }}
    >>>
    >>> src="/get_img.php?{{ urlparameters options="image 3" }}" border="0"
    >>> alt="{{ $campsite->image->description }}">

    >>> {{ /if }}
    >>> {{ if $campsite->article->has_image(4) }}
    >>>
    >>> src="/get_img.php?{{ urlparameters options="image 4" }}" border="0"
    >>> alt="{{ $campsite->image->description }}">

    >>> {{ /if }}
    >>> {{ if $campsite->article->has_image(5) }}
    >>>
    >>> src="/get_img.php?{{ urlparameters options="image 5" }}" border="0"
    >>> alt="{{ $campsite->image->description }}">

    >>> {{ /if }}
    >>> {{ if $campsite->article->has_image(6) }}
    >>>
    >>> src="/get_img.php?{{ urlparameters options="image 6" }}" border="0"
    >>> alt="{{ $campsite->image->description }}">

    >>> {{ /if }}
    >>>


    >>> {{ $campsite->article->name
    >>> }}


    >>>

    {{
    >>> $campsite->article->publish_date|camp_date_format:"%W, %e %M %Y."
    >>> }}


    >>>

    {{ $campsite->article->body->first_paragraph }}


    >>> {{ if $campsite->current_list->at_end }}
    >>>

    >>> {{ if $campsite->current_list->has_previous_elements }}
    >>> <<